from pydantic import BaseModel, Field
from typing import List, Optional


class BaseCommission(BaseModel):
    orders_id: int = Field(0)
    orders_goods_id: int = Field(0)
    goods_id: int = Field(0)
    grow_id: int = Field(0)
    orders_user_id: int = Field(0)
    user_id: int = Field(0)
    user_level: int = Field(0)
    goods_price:float =  Field(0.00)
    level: int = Field(0)
    price: float = Field(0.00)
    status: int = Field(0)

class CommissionCreate(BaseCommission):
    ...

class CommissionUpdate(BaseCommission):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class CommissionStatus(BaseModel):
    data_id: int
    status: int

class BaseIntegral(BaseModel):
    user_id: int = Field(0)
    price: float = Field(0.00)
    direction: int = Field(1)
    type: int = Field(0)
    type_id: int = Field(0)
    expire_at: Optional[str] = Field(None)
    remark: Optional[str] = Field(None)


class IntegralCreate(BaseIntegral):
    ...

class IntegralUpdate(BaseIntegral):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseIntegralRole(BaseModel):
    name: Optional[str] = Field(None)
    value: int = Field(0)
    role: Optional[str] = Field(None)
    remark: Optional[str] = Field(None)
    state: Optional[bool] = True


class IntegralRoleCreate(BaseIntegralRole):
    ...

class IntegralRoleUpdate(BaseIntegralRole):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseLives(BaseModel):
    name: Optional[str] = Field(None)
    cover: Optional[str] = Field(None)
    button_image: Optional[str] = Field(None)
    share_image: Optional[str] = Field(None)
    goods_ids: Optional[str] = Field(None)
    begin_time: Optional[str] = Field("2024-01-01 00:00:00")
    state: Optional[bool] = True


class LivesCreate(BaseLives):
    goods_ids: Optional[list] = None

class LivesUpdate(BaseLives):
    id: int
    goods_ids: Optional[list] = None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})


class BaseDraw(BaseModel):
    user_id: int = Field(0)
    is_got: int = Field(0)
    draw_id: int = Field(0)
    order_id: int = Field(0)
    status: int = Field(0)
    up_time: Optional[str] = Field(None)


class DrawCreate(BaseDraw):
    ...

class DrawUpdate(BaseDraw):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseDrawRole(BaseModel):
    name: Optional[str] = Field(None)
    cover: Optional[str] = Field("", description="封面", example="封面")
    type: int = Field(0)
    type_id: int = Field(0)
    value: int = Field(0)
    role: int = Field(0)
    remark: Optional[str] = Field(None)
    state: Optional[bool] = True


class DrawRoleCreate(BaseDrawRole):
    ...

class DrawRoleUpdate(BaseDrawRole):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseCouponsRole(BaseModel):
    name: Optional[str] = Field(None)
    cover: Optional[str] = Field("", description="封面", example="封面")
    value: int = Field(0)
    role: int = Field(0)
    remark: Optional[str] = Field(None)
    state: Optional[bool] = True
    goods_ids: Optional[str] = Field(None)
    expire_at: int = Field(0)


class CouponsRoleCreate(BaseCouponsRole):
    goods_ids: Optional[list] = None

class CouponsRoleUpdate(BaseCouponsRole):
    id: int
    goods_ids: Optional[list] = None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseCoupons(BaseModel):
    user_id: int = Field(0)
    coupons_id: int = Field(0)
    coupons_price: int = Field(0)
    expire_at: Optional[str] = Field(None)
    is_used: int = Field(0)
    order_id: int = Field(0)
    add_order_id: int = Field(0)
    use_order_id: int = Field(0)
    order_goods_id: int = Field(0)
    remark: Optional[str] = Field(None)
    come_type: int = Field(1)


class CouponsCreate(BaseCoupons):
    ...

class CouponsUpdate(BaseCoupons):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class CouponsCreateIn(BaseModel):
    user_ids: Optional[list] = None
    coupons_id: int = Field(0)
    remark: Optional[str] = Field(None)

class BaseDeposit(BaseModel):
    user_id: int = Field(0)
    price: float = Field(0.00)
    direction: int = Field(1)
    order_id: int = Field(0)
    order_goods_id: int = Field(0)
    goods_id: Optional[int] = Field(0)
    goods_num: Optional[int] = Field(0)
    remark: Optional[str] = Field(None)
    zs_price: float = Field(0.00)


class DepositCreate(BaseDeposit):
    ...

class DepositUpdate(BaseDeposit):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseLevelIntegral(BaseModel):
    user_id: int = Field(0)
    price: float = Field(0.00)
    direction: int = Field(1)
    remark: Optional[str] = Field(None)
    order_id: int = Field(0)


class LevelIntegralCreate(BaseLevelIntegral):
    ...

class LevelIntegralUpdate(BaseLevelIntegral):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})